package game.module.mail.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.PlayingRoleMsgProcessor;
import game.entity.PlayingRole;
import game.module.mail.logic.MailManager;
import lion.common.MsgCodeAnn;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lua.LuaMessageHall.C2SGainMail;
import lua.LuaMessageHall.S2CGainMail;

/**
 * @author: Pomelo.Lee
 * @date: 2017年8月25日 上午11:21:13
 */
@MsgCodeAnn(msgcode = C2SGainMail.id, accessLimit = 500)
public class MailGainProcessor extends PlayingRoleMsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(MailGainProcessor.class);

	@Override
	public void process(PlayingRole playingRole, RequestMessageRaw requestMessage) throws Exception {
		C2SGainMail gainMail = C2SGainMail.parse(requestMessage);
		int playerId = playingRole.getId();
		logger.info("playerId={},gainMailId={}", playerId, gainMail.mail_id);
		MailManager.getInstance().gainMailById(playingRole, gainMail.mail_id);
		S2CGainMail respMsg = new S2CGainMail();
		respMsg.mail_id = gainMail.mail_id;
		playingRole.writeAndFlush(respMsg.build(playingRole.alloc()));
	}

	@Override
	public void processProto(PlayingRole playingRole, RequestProtoMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void processWebsocket(PlayingRole playingRole, MyRequestMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

}
